package cn.alm.allinoneboot.controller;

import cn.alm.allinoneboot.common.CommonResult;
import cn.alm.allinoneboot.dto.CommonDto;
import cn.alm.allinoneboot.service.JedisService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("api/jedis")
public class JedisController {

    @Resource
    JedisService jedisService;

    @PostMapping("getValue")
    public CommonResult getValue(@RequestBody CommonDto dto) {
        String key = dto.getKey();
        CommonResult cr = jedisService.get(key);
        return cr;
    }

    @PostMapping("setValue")
    public CommonResult setValue(@RequestBody CommonDto dto) {
        String key = dto.getKey();
        String value = dto.getValue();
        return jedisService.set(key, value);
    }
}
